<template>
    <div class="child">
        杂种{{money}}
        <div>
            <button @click="updateNum(-1)">-</button>
            <span>{{num}}</span>
            <button @click="updateNum(1)">+</button>
        </div>
    </div>

</template>
<script>
export default {
    props:["money"],
    name:"child",
    data(){
        return{num:0}
    },
    methods:{
        updateNum(n){
            this.num+=n
            //自定义事件
            this.$emit('child-to-parent',this.num)
        }
    }
}
</script>
<style scoped>
button{
    width: 100px;
    height: 30px;
}
</style>